home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / lang / Python16.lha / Python-1.6 / Lib / Python1.6 / distutils / command / install_data.py < prev    next >
Encoding:
Python Source  |  2000-07-27  |  2.1 KB  |  66 lines

  1. """distutils.command.install_data
  2.  
  3. Implements the Distutils 'install_data' command, for installing
  4. platform-independent data files."""
  5.  
  6. # contributed by Bastian Kleineidam
  7.  
  8. __revision__ = "$Id: install_data.py,v 1.11 2000/07/27 02:13:20 gward Exp $"
  9.  
  10. import os
  11. from types import StringType
  12. from distutils.core import Command
  13. from distutils.util import change_root
  14.  
  15. class install_data (Command):
  16.  
  17.     description = "install data files"
  18.  
  19.     user_options = [
  20.         ('install-dir=', 'd',
  21.          "base directory for installing data files "
  22.          "(default: installation base dir)"),
  23.         ('root=', None,
  24.          "install everything relative to this alternate root directory"),
  25.         ]
  26.  
  27.     def initialize_options (self):
  28.         self.install_dir = None
  29.         self.outfiles = []
  30.         self.root = None
  31.         self.data_files = self.distribution.data_files
  32.  
  33.     def finalize_options (self):
  34.         self.set_undefined_options('install',
  35.                                ('install_data', 'install_dir'),
  36.                    ('root', 'root'),
  37.                   )
  38.  
  39.     def run (self):
  40.         self.mkpath(self.install_dir)
  41.         for f in self.data_files:
  42.             if type(f) == StringType:
  43.                 # it's a simple file, so copy it
  44.                 self.warn("setup script did not provide a directory for "
  45.                           "'%s' -- installing right in '%s'" %
  46.                           (f, self.install_dir))
  47.                 out = self.copy_file(f, self.install_dir)
  48.                 self.outfiles.append(out)
  49.             else:
  50.                 # it's a tuple with path to install to and a list of files
  51.                 dir = f[0]
  52.                 if not os.path.isabs(dir):
  53.                     dir = os.path.join(self.install_dir, dir)
  54.                 elif self.root:
  55.                     dir = change_root(self.root, dir)
  56.                 self.mkpath(dir)
  57.                 for data in f[1]:
  58.                     out = self.copy_file(data, dir)
  59.                     self.outfiles.append(out)
  60.  
  61.     def get_inputs (self):
  62.         return self.data_files or []
  63.  
  64.     def get_outputs (self):
  65.         return self.outfiles
  66.